import sys
import re

class roman_numeral:
    def __init__(self):
        pattern = """
        ^                   # begin
        (M{,4})             # thousands
        
        (CD|CM|D?C{,3})     # hundreds
        
        (XL|XC|L?X{,3})     # tens
        
        (IV|IX|V?I{,3})     # ones
        
        $
        """
        
        self.pattern = re.compile(pattern, re.VERBOSE)
        #self.pattern = re.compile(pattern)

    def valid(self, x):
        if self.pattern.search(x) is not None:
            return True;
        return False;

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print "usage: %s n1 n2 n3 ......" %(sys.argv[0], )

    rn = roman_numeral()

    print
    for n in sys.argv[1:]:
        if rn.valid(n):
            print "%s is" % n
        else:
            print "%s not" % n

